#_*_ coding: utf-8 _*_
import requests
from utils import zytoken,zymysql
import json


def mesageuser(msg):
    starturl = 'http://192.168.0.13:4865/seeyon/rest/message/userId'
    zytokenz = zytoken.shen_header()['token']

    headers = {'Content-Type': 'application/json', 'token': zytokenz}
    sql = "select * from org_relationship  where SOURCE_ID='8304736443741717865' and TYPE='Team_Member'"
    resultp = zymysql.seeyon_query(sql)
    userIds = [item[3] for item in resultp]

    send_data = {
        "userIds": userIds,
        # "userIds": [-7539689150772330476],
        "sendUserId" : "-8409815201310029713",
        "content" : msg,
    }
    datas = json.dumps(send_data)
    response = requests.post(starturl, data=datas,headers=headers)
    print(response.json())



if __name__ == '__main__':
    msg = '我是测试信息'
    print(mesageuser(msg))